###########################################################################
#       Copyright (C) 2008 Timothy Clemans <timothy.clemans@gmail.com>
#
#   Released under the New BSD license.
#
###########################################################################

class StringRepresentation(object):
    """
    
    """
    def __init__(self, table):
        self.table = table
        self.col_width = [max([len(row.str) for row in col]) for col in zip(*self.table.data)]
        
    def __repr__(self):
        s = []
        for row in self.table.data:
            s.append(' | '.join([col.str.rjust(self.col_width[i]) for i, col in enumerate(row)]))
        return '\n'.join(s)
    
    __str__ = __repr__